const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
    entry: [
        './src/App.js'
    ],
    output: {
        filename: 'js/[name].js',
        path: path.resolve(__dirname, 'dist'),
        publicPath:"http://localhost:8080/"
    },
    devServer: {
        contentBase: path.resolve(__dirname, 'dist')
    },
    plugins:[
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin({
            filename:"index.html",
            template:"index.html",
            inject:"body"
        })
    ],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    {
                        loader: 'style-loader'
                    },
                    {
                        loader: 'css-loader',
                        options: {
                            //minimize: true //css压缩
                        }
                    }

                ]
            },
            { test: /\.(eot|woff|ttf)$/, loader: "file-loader" },
            {
                test: /\.(jsx|js)$/,
                exclude: path.resolve(__dirname, 'node_modules'),
                include: path.resolve(__dirname, 'src'),
                use: [
                    {
                        loader: 'babel-loader',
                        options:{
                            presets: ['react', 'es2015']
                        }
                    }
                ]
            }
        ]
    }
};